package com.aspose.cells;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

class zcgc {
   static byte[] a(byte[] var0) {
      ByteArrayOutputStream var1 = new ByteArrayOutputStream();
      zcga var2 = new zcga(var1, 9);

      try {
         var2.write(var0, 0, var0.length);
         var2.close();
      } catch (IOException var4) {
         throw new CellsException(18, "Failed to read image data", var4);
      }

      return var1.toByteArray();
   }

   static byte[] a(boolean var0, boolean var1, int var2, int var3, int var4, byte[] var5, int var6) {
      ByteArrayInputStream var7 = new ByteArrayInputStream(var5);
      zcfz var8 = new zcfz(var7);
      ByteArrayOutputStream var9 = new ByteArrayOutputStream();
      byte[] var10 = new byte[512];

      try {
         for(int var11 = var8.a(var10, 0, var10.length); var11 > -1; var11 = var8.a(var10, 0, var10.length)) {
            var9.write(var10, 0, var11);
         }
      } catch (IOException var16) {
         throw new CellsException(18, "Failed to read image data", var16);
      }

      short var17 = 0;
      if (var0) {
         var17 = 22;
      } else if (var1) {
         var17 = 512;
      }

      byte[] var12 = var9.toByteArray();
      if (var0) {
         byte[] var13 = new byte[var17 + var12.length];
         System.arraycopy(var12, 0, var13, 22, var12.length);
         var12 = var13;
         zaks.a(var13, 0, (int)-1698247209);
         short var14 = 22289;
         int var15 = Math.round((float)(var2 * var4) / 96.0F);
         zaks.b(var13, 10, var15);
         int var18 = var14 ^ var15;
         var15 = Math.round((float)(var3 * var4) / 96.0F);
         zaks.b(var13, 12, var15);
         var18 ^= var15;
         zaks.b(var13, 14, var4);
         var18 ^= var4;
         zaks.b(var13, 20, var18);
      }

      return var12;
   }
}
